﻿using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public enum EBattleViewerAction
{
	None,
	RageSkill = 1,
	SummonFriend = 2,
	Attack,
	SupportAtk,
	SupportDef,
	Skill,
	BossAttack,
	BossSkill,
}

[System.Serializable]
public class ModelGradeInfo
{
	public GameObject modelPrefab;
	public string grade;
}

public class BattleViewer : MonoBehaviour {

	private static BattleViewer instance;
	
	public static BattleViewer Instance{
		get{
			return instance;
		}
	}	
	
	void Awake()
	{
		instance = this;
	}

	float btnGapX = 90;
	float btnGapY = 32;
	float btnXStart = 10;//50;
	float btnY = 100;

	public ModelGradeInfo [] playerModelInfo;
	public ModelGradeInfo [] enemyModelInfo;

//	void Start()
//	{
//		SoundController.Create();
//		ResourceManager.Inst.PatchDataFile( ()=> {
//			GameData.Init();
//			CashData.Init();
//			//TextData.Init();
//			EventData.Init();
//		});
//	}

	public bool HasModelInfo()
	{
		if(playerModelInfo.Length>0 && enemyModelInfo.Length>0)
			return true;
		return false;
	}

//	public int GetPlayerModelID(int i)
//	{
//		int nIndex=0;
//		if(i< playerModelInfo.Length)
//			nIndex=i;
//
//		return GameData.Inst.GetModelIDFromName(playerModelInfo[nIndex].modelName);
//	}
//
//	public int GetEnemyModelID(int i)
//	{
//		int nIndex=0;
//		if(i< enemyModelInfo.Length)
//			nIndex=i;
//		
//		return GameData.Inst.GetModelIDFromName(enemyModelInfo[nIndex].modelName);
//	}

	public GameObject GetModelPrefab(int i, bool isPlayer)
	{
		int nIndex=0;
		if(isPlayer) {
			if(i< playerModelInfo.Length)
				nIndex=i;
			return playerModelInfo[nIndex].modelPrefab;
		}
		else {
			if(i< enemyModelInfo.Length)
				nIndex=i;
			return enemyModelInfo[nIndex].modelPrefab;
		}
		return null;
	}

	public string GetGradePostfix(int i, bool isPlayer)
	{
		int nIndex=0;
		if(isPlayer) {
			if(i< playerModelInfo.Length)
				nIndex=i;
			if(!playerModelInfo[nIndex].grade.IsNullOrEmpty())
				return "_" + playerModelInfo[nIndex].grade;
		}
		else {
			if(i< enemyModelInfo.Length)
				nIndex=i;
			if(!enemyModelInfo[nIndex].grade.IsNullOrEmpty())
				return "_" + enemyModelInfo[nIndex].grade;
		}
		return "";
	}

}
